package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * SaasMark枚举
 * @author kaka
 * @time 2019-01-07 15:28
 */
@Getter
public enum SaasMarkEnum {

    /**
     * SaasMark Paas标示
     */
    SAAS(1, "saas", "enum.saasMark.memo.saas", "#FBE5D5"),

    /**
     * SaasMark Paas标示
     */
    PAAS(2, "paas", "enum.saasMark.memo.paas", "#D4E2FB"),

    THIRD_PARTY(3, "thirdParty", "enum.saasMark.memo.third_party", "#DFEFDA")
    ;

    /**
     * 平台标示值
     */
    private Integer code;

    /**
     * 平台标示英文描述
     */
    private String alias;
    /**
     * 平台标示中文描述
     */
    private String memo;

    /**
     * 应用管理界面展示的颜色
     */
    private String color;

    SaasMarkEnum(Integer code, String alias, String memo, String color) {
        this.code = code;
        this.alias = alias;
        this.memo = memo;
        this.color = color;
    }

    public static SaasMarkEnum getMemo(Integer code){
        for(SaasMarkEnum saasMarkEnum: values()){
            if(saasMarkEnum.getCode().equals(code)){
                return saasMarkEnum;
            }
        }
        return null;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }


    public static SaasMarkEnum getByCode(Integer code) {
        for (SaasMarkEnum cache : values()) {

            if (Objects.equals(code, cache.getCode())) {
                return cache;
            }
        }
        return null;
    }
}
